//
//  InfoScene.m
//  ProjectL
//
//  Created by Nguyen Tan Loc on 10/15/13.
//  Copyright (c) 2013 Nguyen Tan Loc. All rights reserved.
//

#import "InfoScene.h"
#import "MenuScene.h"
#import "Utility.h"

@implementation InfoScene

+(CCScene *) scene
{
    CCScene *scene = [CCScene node];
    InfoScene *layer = [InfoScene node];
    [scene addChild:layer];
    return scene;
}

-(id) init
{
    if (self = [super init])
    {
        CGSize winSize = [[CCDirector sharedDirector] winSize];
        CCLabelBMFont *label = [CCLabelBMFont labelWithString:@"Created by Pixeption\nVersion: 1.0" fntFile:FONT_DEFAULT];
        [label setAnchorPoint:ccp(0.5, 0.5)];
        [label setPosition:ccp(winSize.width / 2, winSize.height / 2 + uniPos(50, 100))];
        [self addChild:label];
        
        CCMenu *mainmenu = [[CCMenu alloc] init];
        [mainmenu setPosition:CGPointZero];
        
        CCMenuItem *mMIBack = [CCMenuItemSprite itemWithNormalSprite:[CCSprite spriteWithSpriteFrameName:SFN_BACK]
                                                      selectedSprite:nil
                                                              target:self
                                                            selector:@selector(onBack)];
        [mMIBack setPosition:uniPos(ccp(winSize.width - 20, winSize.height - 20), ccp(winSize.width - 40, winSize.height - 40))];
        mMIBack.activeArea = CGRectMake(-20, -20, mMIBack.contentSize.width + 40, mMIBack.contentSize.height + 40);
        [mainmenu addChild:mMIBack];
        [self addChild:mainmenu];
        
        CCSprite *sprCocos2d = [CCSprite spriteWithFile:@"cocos2d.png"];
        [sprCocos2d setAnchorPoint:ccp(0.5, 0)];
        [sprCocos2d setPosition:ccp(winSize.width / 2, 10)];
        [self addChild:sprCocos2d];
    }
    
    return self;
}

-(void) onBack
{
    [[Utility getInstance] playEffect:SOUND_MENU_BUTTON];
    [[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:0.5 scene:[MenuScene scene]]];
}

@end